/*
 * Copyright (C) 2008+ Spark Zheng
 *
 * @file	include/random.h 
 * @brief       random module
 * @see		dlib
 * @module      dlib
 * @history 
 *      version 0.0.1   Spark Zheng init random module
 *      version 0.0.2   Spark Zheng add random-pickup/shuffle
 * TODO:
 *      -1. multi-random(Mean, Guass, Binary)
 */

#ifndef _DLIB_RANDOM_H
#define _DLIB_RANDOM_H

#ifdef __cplusplus
extern "C" {
#endif

#include "global.h"

/** really random algorithm */
extern int dlib_rand_init(void);
extern void dlib_rand_exit(void);

/** random value generators */
extern uint32_t dlib_rand32(void);
extern uint64_t dlib_rand64(void);

/**
 * dlib_randstr
 * @brief generate random string by size
 * @param dist[out], the out buffer of random string
 * @size random string length, buffer need gt size+1
 */
extern char *dlib_randstr(char *dist, uint32_t size);

/** miscellaneous random functions */
/** 
 * dlib_random_shuffer
 * @brief shuffer algorithm implementation.
 * @param array: objects need to shuffer
 * @param len: array objects(elements) number
 * @param size: sizeof array object
 */
extern void *dlib_random_shuffer(void *array, uint32_t len, uint32_t size);

/** 
 * dlib_random_pickup
 * @brief pick M objects from N objects randomly.
 * @param array: objects from which to pickup
 * @param array_len: array objects(elements) number
 * @param pickup: pickup result array
 * @param pickup_len: pickup objects number
 */
extern void *dlib_random_pickup(void *array, uint32_t array_len, void *pickup,
				uint32_t pickup_len, uint32_t size);

#ifdef __cplusplus
}
#endif
#endif
